package org.bluedream.core.module.dao.bill.stkIn;

import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.bluedream.core.module.entity.bill.ord.Ord;
import org.bluedream.core.module.entity.bill.stkIn.StkIn;
import org.bluedream.core.module.entity.bill.stkIn.dtl.StkInDtl;

import java.io.Serializable;

/**
 * @ClassName StkInDao
 * @Description TODO
 * @Author foxsand
 * @Data 14:46
 * @Version
 */
public interface StkInDao extends BaseMapper<StkIn> {

    @Override
    @Select("select stkIn.bill_type as billType , stkIn.bill_num as billNum , stkIn.check_date as checkDate , stkIn.check_by as checkBy , stkIn.org_code as orgCode , " +
            "stkIn.war_code as warCode , c.name as warName , " +
            "stkIn.supplier_code as supplierCode , b.name as supplierName , stkIn.qty as qty , stkIn.total as total , " +
            " stkIn.id as id , stkIn.create_by as createBy , stkIn.create_date as createDate , stkIn.update_by as updateBy , stkIn.update_date as updateDate , stkIn.status as status , stkIn.remarks as remarks" +
            " from StkIn StkIn, tSupplier b , warehouse c " +
            "${ew.customSqlSegment} and stkIn.supplier_code = b.code and stkIn.war_code = c.code")
    IPage<StkIn> selectPage(IPage<StkIn> page, @Param("ew") Wrapper<StkIn> queryWrapper);

    @Override
    @Select("select stkIn.bill_type as billType , stkIn.bill_num as billNum , stkIn.check_date as checkDate , check_by as checkBy , stkIn.org_code as orgCode , " +
            "stkIn.war_code as warCode , wareHouse.name as warName , " +
            "stkIn.supplier_code as supplierCode , supplier.name as supplierName , stkIn.qty as qty , stkIn.total as total , " +
            " stkIn.id as id , stkIn.create_by as createBy , stkIn.create_date as createDate , stkIn.update_by as updateBy , stkIn.update_date as updateDate , stkIn.status as status , stkIn.remarks as remarks , " +
            " supplier.id as \"supplier.id\" , supplier.code as \"supplier.code\" , supplier.name as \"supplier.name\" , " +
            " wareHouse.id as \"wareHouse.id\" , wareHouse.code as \"wareHouse.code\" , wareHouse.name as \"wareHouse.name\"" +
            " from StkIn stkIn, tSupplier supplier , warehouse wareHouse " +
            "where stkIn.id = #{id} and stkIn.supplier_code = supplier.code and stkIn.war_code = wareHouse.code")
    StkIn selectById(Serializable id);

    String excelImport(StkInDtl stkInDtl);
}
